<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改缓存线管理')"/>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-shelfPlan-edit" th:object="${shelfPlan}">
            <input id="id" name="id" th:field="*{id}" type="hidden">
            <input id="shelfId" name="shelfId" th:field="*{shelfId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">缓存线编码：</label>
                <div class="col-sm-8">
                    <input id="shelfCode" name="shelfCode" th:field="*{shelfCode}" class="form-control" disabled="disabled" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">缓存线状态：</label>
                <div class="col-sm-8">
                    <select id="state" name="state" th:field="*{state}" class="form-control" @change="changeShow()">
                        <option value="1">OK</option>
                        <option value="-1">NG</option>
                    </select>
                </div>
            </div>
            <div class="form-group" v-if="show">
                <label class="col-sm-3 control-label">NG原因：</label>
                <div class="col-sm-8">
                    <input id="description" name="description" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单晶PN型：</label>
                <div class="col-sm-8">
                    <select id="materialPN" name="materialPN" th:field="*{materialPN}" class="form-control">
                        <option value="P">P</option>
                        <option value="N">N</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户等级：</label>
                <div class="col-sm-8">
                    <select id="materialCategory" name="materialCategory" th:field="*{materialCategory}" class="form-control">
                        <option value="A">A</option>
                        <option value="A+H">A+H</option>
                        <option value="A-">A-</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单晶规格：</label>
                <div class="col-sm-8">
                    <select id="spec" name="spec" th:field="*{spec}" class="form-control">
                        <option value="G12">G12</option>
                        <option value="M6">M6</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">拼棒类型：</label>
                <div class="col-sm-8">
                    <select id="assemblyType" name="assemblyType" th:field="*{assemblyType}" class="form-control">
                        <option value="1">整棒</option>
                        <option value="2">二拼</option>
                        <option value="3">三拼</option>
                    </select>
                </div>
            </div>
        </form>
        <form th:object="${shelfPlan}">
            <input id="checkState" th:field="*{state}" type="hidden">
        </form>
    </div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "ShelfPlan";

    function submitHandler(){
        if($.validate.form()){
            $.operate.save(prefix + "/edit", $('#form-shelfPlan-edit').serialize());
        }
    }

    var app = new Vue({
        el: '.wrapper',
        data: {
            show: false,
            oldState: ''
        },
        methods: {
            changeShow(){
                var currentSel = document.getElementById('state');
                var index = currentSel.selectedIndex;
                var value = currentSel.options[index].value;
                if(value == this.oldState){
                    this.show = false;
                }else{
                    if(value == -1){
                        this.show = true;
                    }else{
                        this.show = false;
                    }
                }
            }
        },
        created(){
            this.oldState = document.querySelector('#checkState').value;
        }
    })
</script>
</body>
</html>
